#include<iostream>
#include<algorithm>
using namespace std;
const int N=1e4+10;
struct man{
	int id,cnt;
	int res;
	man(){
		cnt=0,res=0;
	}
}arr[N];
bool cmp(man a,man b){
	if(a.res==b.res){
		if(a.cnt==b.cnt){
			return a.id<b.id;
		}
		return a.cnt>b.cnt;
	}
	return a.res>b.res;
}
int n;
int main()
{
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		int k;
		double sum=0;
		cin>>k;
		arr[i].id=i;
		for(int j=0;j<k;j++)
		{
			int id;
			int p;
			cin>>id>>p;
			sum+=p;
			arr[id].res+=p;
			arr[id].cnt++;
		}
		arr[i].res-=sum;
	}
	sort(arr+1,arr+n+1,cmp);
	for(int i=1;i<=n;i++)
		printf("%d %.2lf\n",arr[i].id,(double)arr[i].res/100);
	return 0;
}
